
/**
 * 
 */
package com.zsrt.day20170411.homework;

import java.util.Scanner;

import org.junit.Test;


/**
 * 1.判断有多少人的分数在70~80之间
 * 2.判断及格的人有谁
 * 3.判断分数个位数是6的同学是谁
 * 4.判断男生有多少，女生有多少
 * 
 * @author jmj
 * @date 2017年4月11日
 * @time 下午3:59:42
 */
public class StudentTest {
	
	
	@SuppressWarnings("resource")
	@Test
	public void test() throws Exception {
		Student[] students = new Student[4];
		String[] names ={"贾梦菊","张嘉源","罗智壕","何小强"};
		int[] ages ={21,22,23,24};
		int[] scores ={67,78,79,56};
		char[] sexs ={'女','男','男','男'};
		for(int i = 0; i < students.length; i++){
			students[i] = new Student(names[i],ages[i],scores[i],sexs[i]);
			System.out.println(students[i].info());
	    }
	    Student[] newStudents = new Student[5];
	    
	    //添加一個新的信息
	    Scanner in = new Scanner(System.in);
		System.out.println("请输入您的名字");
		String name = in.nextLine();
		//判断是否有误
		if(2<=name.length() && name.length()<=4){

		}else{
			System.out.println("您输入的名字有误。");
			//如果信息有误就结束程序
			return;
		}
		System.out.println("请输入您的性别");
		//用Scanner输入一个字符
		String xbs = in.next();
		char sex = xbs.charAt(0);
		//判断是否有误
		if(sex=='男' || sex=='女'){

		}else{
			System.out.println("您输入的性别有误。");
			return;
		}
		
		System.out.println("请输入您的年龄");
		int age = in.nextInt();
		if(age>0 && age<120){
			
		}else{
			System.out.println("您输入的年龄有误。");
			return;
		}
		
		System.out.println("请输入您的分数");
		int score = in.nextInt();
		if(score>=0 && score<=100){
			
		}else{
			System.out.println("您输入的分数有误。");
			return;
		}
		
		in.close();
	    for(int i =0;i<newStudents.length;i++){
	    	newStudents[i]=new Student();
	    	if(i<4){
	    		//复制原有的数据
	    		newStudents[i]=students[i];
	    	}else{
	    		//添加入新的信息
	    		newStudents[i].setName(name);
	    		newStudents[i].setAge(age);;
	    		newStudents[i].setScore(score);;
	    		newStudents[i].setSex(sex);
	    	}
	    	//输出学生的个人信息
	    	System.out.println(newStudents[i].info());
	    }
	    
	    Student student = new Student();
	    //判断有多少人的分数在70~80之间
	    int num = student.panDuan(newStudents);
	    System.out.println(num);
	    
	    //判断及格的人有谁
	    System.out.println("============================");
	    student.jiGe(newStudents);
	    //判断分数个位数是6的同学是谁
	    System.out.println("============================");
	    student.fs6(newStudents);
	    System.out.println("============================");
	    
	    //判断男生有多少，女生有多少
	    student.xb(newStudents);
	
	
	
	
	
	
	}
		
		
}
